From 83ccc6d027554527d84b9883c08145fce8193454 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Sun, 17 Sep 2017 20:24:16 +0200 Subject: [PATCH] babl: make powf approximation yield 0 for negatives --- babl/babl-trc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/babl/babl-trc.c b/babl/babl-trc.c index 7d9f82f..7524ef8 100644 --- a/babl/babl-trc.c +++ b/babl/babl-trc.c @@ -93,10 +93,11 @@ static inline float _babl_trc_gamma_to_linear (const Babl *trc_, float value) { return babl_polynomial_eval (&trc->poly_gamma_to_linear, value); } - else + else if (value > 0.0f) { return powf (value, trc->gamma); } + return 0.0f; } static inline float _babl_trc_gamma_from_linear (const Babl *trc_, float value) @@ -107,10 +108,11 @@ static inline float _babl_trc_gamma_from_linear (const Babl *trc_, float value) { return babl_polynomial_eval (&trc->poly_gamma_from_linear, value); } - else + else if (value > 0.0f) { return powf (value, trc->rgamma); } + return 0.0f; } static inline void _babl_trc_gamma_to_linear_buf (const Babl *trc_, const float *in, float *out, int in_gap, int out_gap, int components, int count) -- 2.30.2